package collections.tree;


public class TreeElement <T> {
    private T value;
    private TreeElement rootElem, leftNode, rightNode;

    public TreeElement(T t) {
        this.value = t;
    }

    public TreeElement getRootElem() {
        return rootElem;
    }

    public void setRootElem(TreeElement rootElem) {
        this.rootElem = rootElem;
    }

    public TreeElement getLeftNode() {
        return leftNode;
    }

    public void setLeftNode(TreeElement leftNode) {
        this.leftNode = leftNode;
    }

    public TreeElement getRightNode() {
        return rightNode;
    }

    public void setRightNode(TreeElement rightNode) {
        this.rightNode = rightNode;
    }

    public T getValue() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || value.getClass() != o.getClass()) return false;
        if (value != null) return value.equals(o);
        return true;
    }

    @Override
    public int hashCode() {
        return value != null ? value.hashCode() : 0;
    }

    @Override
    public String toString() {
        return value.toString();
    }
}

